<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Welcome to PMS</title>
        <link href="css/stylelog.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
    </head>
    <script>
        $(document).ready(function(){            
            show_error("<%= request.getAttribute("errorMessage")%>");                 
        });
    </script>
    <script type="text/javascript">
       
           
        function show_error(val)
        {   
            if(val != "null")
            {
                var msgErr = val.toString();
                if(msgErr != "" && msgErr!="1"){
                    if(msgErr != "-1") {
                        alert(msgErr);
                    }
                    else{
                        alert("Data error!!!")
                    }                                        
                }                                    
                else
                    return false;
            }
            else{
                return false;
            }
        }                   
                            
        function validateForm()
        {
            var x=document.forms["LoginForm"]["username"].value;
            var y=document.forms["LoginForm"]["password"].value;
            var msgErr ="";
            if (x==null || x=="")
            {
                msgErr = "User name must be filled out";                
            }
            if (y==null || y=="")
            {
                msgErr = msgErr + "\nPassword must be filled out";                
            }
            if(y!="" && y.toString().length < 6)
            {
                msgErr = msgErr + "\nPassword can not be less than 6 characters.";
            }
            if(msgErr != ""){
                alert(msgErr);
                return false;
            }                
        }
        
    </script>
    <body>
        <div id="layer01_holder">
            <div id="left"></div>
            <div id="center"></div>
            <div id="right"></div>
        </div>

        <div id="layer02_holder">
            <div id="left"></div>
            <div id="center"></div>
            <div id="right"></div>
        </div>

        <div id="layer03_holder">
            <div id="left"></div>
            <div id="center">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>LOGIN<br /><br /></td>
                    </tr>
                    <tr>
                        <td>  <html:form action="/login">
                                <tbody>                                        
                                    <tr>
                                        <td>Tài khoản: </td>

                                        <td><html:text name="LoginForm" property="username"/> </td>
                                        <td><html:errors property="username" /> </td>
                                    </tr>
                                    <tr>
                                        <td>Mật khẩu: </td>
                                        <td><html:password name="LoginForm" property="password"/></td>
                                        <td><html:errors property="password" /></td>
                                    </tr>
                                    <tr>
                                        <td><html:submit value="Submit" onclick="return validateForm()"/></td>
                                    </tr>
                                </tbody>
                            </html:form>   </td>
                    </tr>
                </table>
            </div>
            <div id="right"></div>
        </div>

        <div id="layer04_holder">
            <div id="left"></div>
            <div id="center">
                If you forgot your password, please contact administrator.</div>
            <div id="right"></div>
        </div>

        <div id="layer05_holder">
            <div align="left">Copyright © 2011, Team A Design</div>
        </div>
    </body>
</html>